package cn.cvs.service.Impl;

import cn.cvs.dao.SysUserMapper;
import cn.cvs.pojo.SysUser;
import cn.cvs.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private  SysUserMapper sysUserMapper;
    @Qualifier("sysUserMapper")
    private SysUserMapper dao;

    public void setDao(SysUserMapper dao) {
        this.dao = dao;
    }

    @Override
    public SysUser findByAccount(String account) {
        return dao.findByAccount(account);
    }

    @Override
    public SysUser login(String account, String password) {

        SysUser sysUser =sysUserMapper.findByAccount(account);
        if (sysUser == null){
            return null;
        }
        if (!password.equals(sysUser.getPassword())){
            return null;
        }
        return sysUser;
    }

    @Override
    public List<SysUser> list() {
        List<SysUser> list = sysUserMapper.list();
        return list;
    }

    @Override
    public int add(SysUser sysUser) {
        return sysUserMapper.add(sysUser);
    }
}

